<?php

class WebserviceController extends Controller
{
	public function actions()
        {
            return array(
                'ws'=>array(
                    'class'=>'CWebServiceAction'
                ),
            );
        }
        /**
        * @return integer
        * @soap
        */
        public function getPrice()
        {
            return 1;
            //...return stock price for $symbol
        }
        /**
        * @param string ten dang nhap
        * @param string mat khau
        * @param integer
        * @return integer
        * @soap
        */
        public function themAlbum($tenalbum, $mota, $user)
        {
            $model = new Album();
            $model->id_thanh_vien = $user;
            $model->ten_album = $tenalbum;
            $model->mo_ta = $mota;
            $model->thoi_diem_tao = date("Y-m-d h:s:i");
            $model->save();
            return $model->id;
        }
        /**
        * @param integer ten dang nhap
        * @param string mat khau
        * @return integer
        * @soap
        */
        public function themAnh($idAlbum, $tenhinh)
        {
            $model = new Hinh();
            $model->id_album = $idAlbum;
            $model->ten_hinh = $tenhinh;
            $model->mo_ta = "empty";
            $model->url = "empty";
            $model->thoi_diem_upload = date("Y-m-d h:s:i");
            $model->save();
            return $model->id;
        }
        /**
        * @return integer
        * @soap
        */
        public function layAlbumId()
        {
            $connection=Yii::app()->db;
            $sql = "SELECT max(id) as max FROM album";
            $command=$connection->createCommand($sql);
            $dataReader=$command->query();
            foreach($dataReader as $row) { 
                return $row['max'];
            }
        }
}